package com.yuantu.judiciary.controller;

import cn.hutool.crypto.asymmetric.Sign;
import com.yuantu.judiciary.annotation.External;
import com.yuantu.judiciary.common.Response;
import com.yuantu.judiciary.common.ResponseFactory;
import com.yuantu.judiciary.model.dto.SignDTO;
import com.yuantu.judiciary.model.form.QueryInfoForm;
import com.yuantu.judiciary.model.vo.EntListVO;
import com.yuantu.judiciary.model.vo.PageVO;
import com.yuantu.judiciary.service.IApiExternalService;
import com.yuantu.judiciary.service.ICheckEnterpriseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.validation.constraints.NotBlank;

/**
 * 外部接口调用
 *
 * @author syw
 * @since 2023-06-29
 **/
@RestController
@RequestMapping(value = "/external/open")
@Api(tags = "外部接口")
@RequiredArgsConstructor
public class ApiExternalController {

    private final IApiExternalService apiExternalService;

    @ApiOperation(value = "查询个人/公司司法案件数量(张涛)")
    @PostMapping("/case/num")
    public Response<String> queryCaseNum(@Validated @RequestBody QueryInfoForm data) {
        return ResponseFactory.okResponse(apiExternalService.queryCaseNum(data));
    }

    @External
    @ApiOperation(value = "获取模糊搜索企业名称列表")
    @PostMapping("/get/enterprise-list")
    public Response<String> getEnterpriseList(HttpServletRequest request,
                                              @Validated @RequestBody SignDTO signInfo) {
        String sign = signInfo.getSign();
        return ResponseFactory.okResponse(apiExternalService.getEnterpriseList(request, sign));
    }

    @External
    @ApiOperation(value = "查询公司税收违法案件信息(省工商联)")
    @PostMapping("/company/tax/break")
    public Response<String> queryCompanyTaxBreakInfo(HttpServletRequest request, @Validated @RequestBody SignDTO signInfo) {
        String sign = signInfo.getSign();
        return ResponseFactory.okResponse(apiExternalService.queryCompanyTaxBreakInfo(request, sign));
    }

    @External
    @ApiOperation(value = "查询公司行政处罚案件信息(省工商联)")
    @PostMapping("/company/admin/punish")
    public Response<String> queryCompanyAdminPunishInfo(HttpServletRequest request, @Validated @RequestBody SignDTO signInfo) {
        String sign = signInfo.getSign();
        return ResponseFactory.okResponse(apiExternalService.queryCompanyAdminPunishInfo(request, sign));
    }

    @External
    @ApiOperation(value = "查询公司涉诉案件信息(省工商联)")
    @PostMapping("/company/judicial")
    public Response<String> queryCompanyJudicialCaseInfo(HttpServletRequest request, @Validated @RequestBody SignDTO signInfo) {
        String sign = signInfo.getSign();
        return ResponseFactory.okResponse(apiExternalService.queryCompanyJudicialCaseInfo(request, sign));
    }

    @External
    @ApiOperation(value = "查询公司强制清算与破产案件信息(省工商联)")
    @PostMapping("/company/bankrupt")
    public Response<String> queryCompanyBankruptCaseInfo(HttpServletRequest request, @Validated @RequestBody SignDTO signInfo) {
        String sign = signInfo.getSign();
        return ResponseFactory.okResponse(apiExternalService.queryCompanyBankruptCaseInfo(request, sign));
    }

    @External
    @ApiOperation(value = "查询公司失信案件信息(省工商联)")
    @PostMapping("/company/dishonest")
    public Response<String> queryCompanyDishonestCaseInfo(HttpServletRequest request, @Validated @RequestBody SignDTO signInfo) {
        String sign = signInfo.getSign();
        return ResponseFactory.okResponse(apiExternalService.queryCompanyDishonestCaseInfo(request, sign));
    }

    @External
    @ApiOperation(value = "查询公司限制高消案件信息(省工商联)")
    @PostMapping("/company/high/limit")
    public Response<String> queryCompanyHighLimitCaseInfo(HttpServletRequest request, @Validated @RequestBody SignDTO signInfo) {
        String sign = signInfo.getSign();
        return ResponseFactory.okResponse(apiExternalService.queryCompanyHighLimitCaseInfo(request, sign));
    }

    @External
    @ApiOperation(value = "查询个人涉诉案件信息(省工商联)")
    @PostMapping("/person/judicial")
    public Response<String> queryPersonJudicialCaseInfo(HttpServletRequest request, @Validated @RequestBody SignDTO signInfo) {
        String sign = signInfo.getSign();
        return ResponseFactory.okResponse(apiExternalService.queryPersonJudicialCaseInfo(request, sign));
    }

    @External
    @ApiOperation(value = "查询个人破产清算案件信息(省工商联)")
    @PostMapping("/person/bankrupt")
    public Response<String> queryPersonBankruptCaseInfo(HttpServletRequest request, @Validated @RequestBody SignDTO signInfo) {
        String sign = signInfo.getSign();
        return ResponseFactory.okResponse(apiExternalService.queryPersonBankruptCaseInfo(request, sign));
    }

    @External
    @ApiOperation(value = "查询个人失信案件信息(省工商联)")
    @PostMapping("/person/dishonest")
    public Response<String> queryPersonDishonestCaseInfo(HttpServletRequest request, @Validated @RequestBody SignDTO signInfo) {
        String sign = signInfo.getSign();
        return ResponseFactory.okResponse(apiExternalService.queryPersonDishonestCaseInfo(request, sign));
    }

    @External
    @ApiOperation(value = "查询个人限制高消案件信息(省工商联)")
    @PostMapping("/person/high/limit")
    public Response<String> queryPersonHighLimitCaseInfo(HttpServletRequest request, @Validated @RequestBody SignDTO signInfo) {
        String sign = signInfo.getSign();
        return ResponseFactory.okResponse(apiExternalService.queryPersonHighLimitCaseInfo(request, sign));
    }


}
